<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of notesModelClass
 *
 * @author nstevens
 */
class notesModelClass extends commonModel {

    public function __construct() {
        
    }

    /**
     * Updates the given note to completed
     * @param type $index
     * @return null
     */
    public function processNotesMarkAsCompleteRequest($index) {
        $notes = $_POST['notes' . $index . ''];
        $wbsId = $_POST['wbs' . $index . ''];
        $lastUpdated = date("Y-m-d");
        $updateResult = executeUpdate("UPDATE notes SET status=\"completed\", lastUpdated='$lastUpdated' WHERE wbsId='$wbsId' AND notes='$notes'");
        if ($updateResult) {
            return 'location:'.$this->getUrlSource().'&update=Note Marked as Complete';
        }
        return NULL;
    }

    public function processEditNotesRequest($index){
        //print_r($_POST);
        $notes = $_POST['textFieldNotes' . $index . ''];
        $notesID = $_POST['notesID' . $index . ''];
        $lastUpdated = date("Y-m-d");
        $updateResult = executeUpdate("UPDATE notes SET notes='$notes', lastUpdated='$lastUpdated' WHERE notesId=$notesID");
        if ($updateResult) {
            //echo "UPDATE notes SET notes='$notes', lastUpdated='$lastUpdated' WHERE notesId=$notesID";
            return 'location:'.$this->getUrlSource().'&update=Notes Updated Successfully';
        }
        return NULL;
    }
}
?>
